$(function(){
	var ind = 1;
	var sidebarUlLeft = $(".sidebarUlLeft").find(".navlistchage");
	sidebarUlLeft.click(function(){
	 	updataImg($(this));
	})
	
	function updataImg(_this){
		var _index = _this.index()+1;
		ind = _index;
		_this.removeClass("colorB");
		_this.children().removeClass("hreadChages");
		_this.siblings(".bhover").addClass("colorB");
		$(".contextRight"+_index).css("display","block").siblings(".contextMargin").css("display","none");
		_this.addClass("hreadChage").siblings().removeClass("hreadChage");
		
		var navImg = ($(".sidebar-collapse").hasClass("chageMin")) ? "img/icon_hover"+_index+".png" : "img/bang_"+_index+".png";
		var navImg1 = ($(".sidebar-collapse").hasClass("chageMin")) ? "img/icon1.png" : "img/bang1.png";
		var navImg2 = ($(".sidebar-collapse").hasClass("chageMin")) ? "img/icon2.png" : "img/bang2.png";
		/*var navImg3 = ($(".sidebar-collapse").hasClass("chageMin")) ? "img/icon3.png" : "img/bang3.png";*/
		if(_index == 1){
			_this.children().children().attr("src",navImg);
			$(".class2").children().children().attr("src",navImg2);
			/*$(".class3").children().children().attr("src",navImg3);*/
			$(".leftArrow").css("top","15%");
			
		}else if(_index == 2){
			_this.children().children().attr("src",navImg);
			$(".class1").children().children().attr("src",navImg1);
			/*$(".class3").children().children().attr("src",navImg3);*/
			$(".leftArrow").css("top","48%");
			redirectPage();
			
		}/*else if(_index == 3){
			_this.children().children().attr("src",navImg);
			$(".class1").children().children().attr("src",navImg1);
			$(".class2").children().children().attr("src",navImg2);
			$(".leftArrow").css("top","83%");
		}*/
	}
	
	sidebarUlLeft.hover(function(){
		var _index = $(this).index()+1;
		sidebarUlLeftIn(_index,$(this));
	},function(){
		var _index = $(this).index()+1;
		sidebarUlLeftOut(_index,$(this));
	})
	
	function sidebarUlLeftIn(_index,_this){
		if(_this.hasClass("hreadChage")) return
		
		$(".sidebar-collapse").hasClass("chageMin") ? _this.children().children().attr("src","img/icon_hover"+_index+".png") : _this.children().children().attr("src","img/bang_"+_index+".png");
		
		_this.children().addClass("colorD hreadChages");
	}
	function sidebarUlLeftOut(_index,_this){
		if(_this.hasClass("hreadChage")) return
		
		$(".sidebar-collapse").hasClass("chageMin") ? _this.children().children().attr("src","img/icon"+_index+".png") : _this.children().children().attr("src","img/bang"+_index+".png");
		
		_this.children().removeClass("colorD hreadChages");
	}
	/*输入框的变色*/
	$("input,textarea,select").focus(function(){
		$(this).css("border","1px #354052 solid");
	})
	$("input,textarea,select").blur(function(){
		$(this).css("border","0px #354052 solid");
	})
	
	$(".listing").focus(function(){
		$(this).parent().siblings(".listingmsg").css("display","block")
	})
	$(".listing").blur(function(){
		$(this).parent().siblings(".listingmsg").css("display","none")
	})
	
	
	/*导航栏的选中颜色*/
	var labeichageA = $(".labeichage").find("a");
	labeichageA.hover(function(){
		$(this).addClass("headerNav");
	},function(){
		$(this).removeClass("headerNav");
	})
	/*模态弹出框*/
	$(".resultBtn").click(function(){
		$(".modalAlert").css("display","block");
	});
	
	$(".closeBtn").click(function(){
		$(".modalAlert").css("display","none");
	})
	
	/*$(".modalRuleBtn").click(function(){
		$(".modalRule").css("display","block");
	});
	
	$(".closeBtnRule").click(function(){
		$(".modalRule").css("display","none");
	})*/
	
	/*关键词分析自动生成数据*/
	function updataH(){
		var tab1Height = $(".btnmore").height();
		var keyH = $(".bgcolorMidK").height();
		if(tab1Height>=900){
			$(".bgcolorMid").css("height",tab1Height-170);
		}
	}
	updataH();			
	$(".addBtn").click(function(){
		/*每一个table的数量不能超过40包括（40），超过40就自动生成一个table，以此类推*/
		var trLength = $(".ct_tableContainer:last-child").children("table").children("tbody").find("tr").length;
	
		if(trLength>120){
			/*整个table的数量*/
			var ct_length = $(".ct_tableContainer").length+1;
			var _html = " ";
			if(ct_length % 3 == 2){
				_html +='<div class="ct_tableContainer ct_table_padding">';
			}else{
				_html +='<div class="ct_tableContainer">';
			}
			_html +='<table class="ct_table">';
			_html +='<thead>';
			_html +='<tr class="tableStyle">';
			_html +='<th>aa</th><th>1</th><th>1%</th>';
			_html +='</tr>';
			_html +='</thead>';
			_html +='<tbody>';
			_html +='<tr><td>aa</td><td>1</td><td>1%</td></tr>';
			_html +='<tr><td>aa</td><td>1</td><td>1%</td></tr>';
			_html +='<tr><td>aa</td><td>1</td><td>1%</td></tr>';
			_html +='<tr><td>aa</td><td>1</td><td>1%</td></tr>';
			_html +='</tbody>';
			_html +='</table>';
			_html +='</div>';
			
			$(".ct_context").append(_html);
		}
		updataH();
	})
	
	/*清空文本域的值*/
	$(".clearBtn").on("click",function(){
		$(".clearText").val(" ");
		$(".clearText").focus();
	})
	
	/*左边导航栏*/
	$(".sidebar-collapse").on("click",function(){
		if($(this).hasClass("chageMin")){
			$(this).removeClass("chageMin");
			$(".sidebar-toggle .ace-icon img").attr("src","img/lefts.png")
			$(".sidebarUlLeft li a img").css({"width":"91px","height":"90px"});
			$(".updataImg img").css({"width":"73px","height":"67px"});
			var imgout1 = (ind == 1) ? "img/bang_1.png" : "img/bang1.png";
			var imgout2 = (ind == 2) ? "img/bang_2.png" : "img/bang2.png";
			$(".class1").children().children().attr("src",imgout1);
			$(".class2").children().children().attr("src",imgout2);
			$(".class3").children().children().attr("src","img/bang3.png");
		}else{
			$(this).addClass("chageMin");
			$(".sidebar-toggle .ace-icon img").attr("src","img/rights.png")
			$(".sidebarUlLeft li a img").css({"width":"32px","height":"32px"});
			$(".updataImg img").css({"width":"43px","height":"39px"});
			var imgIn1 = (ind == 1) ? "img/icon_hover1.png" : "img/icon1.png";
			var imgIn2 = (ind == 2) ? "img/icon_hover2.png" : "img/icon2.png";
			$(".class1").children().children().attr("src",imgIn1);
			$(".class2").children().children().attr("src",imgIn2);
			$(".class3").children().children().attr("src","img/icon3.png");
		}
		
	})
	
	
	/*下拉框的选择功能*/
	var flayIndex = false;
	var menu = $(".delayed").find("li");
	menu.on("click",function(){
		$(".delayedInput").val($(this).children().html())
		flayIndex = true;
	})
	
	var flayIndexs = false;
	var proportion = $(".proportion").find("li");
	proportion.on("click",function(){
		$(".proportionInput").val($(this).children().html())
		flayIndexs = true;
	})
	
	/*检测分辨率是否是小屏幕*/
	function redirectPage(){
		var screenWh = screen.width;
		if(screenWh <= 1366){
			//var navH = $(".navbar").css("height")+30;
			$('body,html').animate({ scrollTop: 200 }, 800);
		}
	}
	
	
	$(".checkGroup").on("click",function(){
		if($(this).children("i").hasClass("okBtn")){
			$(this).children("i").removeClass("okBtn glyphicon glyphicon-ok");
		}else{
			$(this).children("i").addClass("okBtn glyphicon glyphicon-ok");
		}
	})
				
	$(".radioContainer .radioGroup").on("click",function(){
		
		if($(this).children().children("i").hasClass("logo")){
			return;
		}
		if(!$(this).children().children("i").hasClass("radioLogo")){
			$(this).children().children("i").addClass("radioLogo logo");
			$(this).siblings().children().children().removeClass("radioLogo logo");
		}
	})
	
	
	/*提示框的效果*/
	$(".tooltipBtn").hover(function(){
		$(this).siblings(".tool").css("display","block");
	},function(){
		$(this).siblings(".tool").css("display","none");
	})
	
	function newDataTime(){
		var date = new Date();
		var Time = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
			Time +=" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
			$(".Time").html("中国银行"+Time);
	}
	newDataTime();
/*	$("#txtKeywordsMaxNum").on("keyup",function(){
		var maxNum = $(this).val();
		var re = new RegExp(/[^\d]/);
		console.log(re.test(maxNum))
		maxNum.replace(re,'');
	})*/
});
